package com.xukai.springboot.controller.sys;

import com.xukai.springboot.entity.request.sys.DelRoleRequest;
import com.xukai.springboot.entity.request.sys.EditAuthorityRequest;
import com.xukai.springboot.entity.request.sys.StopRoleRequest;
import com.xukai.springboot.entity.response.PageResult;
import com.xukai.springboot.entity.response.ResponseBase;
import com.xukai.springboot.entity.sys.t_sys_authority;
import com.xukai.springboot.entity.sys.t_sys_role;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@Api(basePath = "api/sys/role", description = "角色管理")
@RestController
@RequestMapping("api/sys/role/*")
public class RoleController {

    /**
     * 日志
     */
    private final Logger logger = LoggerFactory.getLogger(UserController.class);

    /**
     * 获取角色列表
     */
    @ApiOperation(value = "获取角色列表", notes = "获取角色列表")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "StartIndex", value = "检索起始数据", required = true, dataType = "int", example = "0",defaultValue ="0" , paramType = "query"),
            @ApiImplicitParam(name = "PageSize", value = "分页大小", required = true, dataType = "int", example = "0",defaultValue ="0" , paramType = "query"),
            @ApiImplicitParam(name = "RoleName", value = "角色名称", required = true, dataType = "string", example = "0", paramType = "query")
    })
    @GetMapping("GetUserRoleList")
    public ResponseBase<PageResult<t_sys_role>> GetUserRoleList(@RequestParam int StartIndex, @RequestParam int PageSize, @RequestParam String RoleName) {

        ResponseBase<PageResult<t_sys_role>> result = new ResponseBase<>();
        try {

        } catch (Exception e) {
            logger.error("获取角色列表", e);
            result.setStatue(0);
        }
        return result;
    }

    /**
     * 获取角色详情
     *
     * @return
     */
    @ApiOperation(value = "获取角色详情", notes = "获取角色详情")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "RoleID", value = "角色ID", required = true, dataType = "int", example = "0",defaultValue ="0" , paramType = "query")
    })
    @GetMapping("GetUserRole")
    public ResponseBase<t_sys_role> GetUserRole(@RequestParam int RoleID) {
        ResponseBase<t_sys_role> result = new ResponseBase<>();
        try {
        } catch (Exception e) {
            logger.error("获取角色详情", e);
            result.setStatue(0);
        }
        return result;
    }

    /**
     * 新建角色
     */
    @ApiOperation(value = "新建角色", notes = "新建角色")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "Param", value = "角色信息", required = true, dataType = "t_sys_role", paramType = "body")
    })
    @PostMapping("CreateUserRole")
    public ResponseBase<t_sys_role> CreateUserRole(@RequestBody t_sys_role Param) {
        ResponseBase<t_sys_role> result = new ResponseBase<>();
        try {

        } catch (Exception e) {
            logger.error("新建角色", e);
            result.setStatue(0);
        }
        return result;
    }

    /**
     * 编辑角色
     */
    @ApiOperation(value = "编辑角色", notes = "编辑角色")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "Param", value = "角色信息", required = true, dataType = "t_sys_role", paramType = "body")
    })
    @PostMapping("EidtUserRole")
    public ResponseBase<t_sys_role> EidtUserRole(@RequestBody t_sys_role Param) {
        ResponseBase<t_sys_role> result = new ResponseBase<>();
        try {

        } catch (Exception e) {
            logger.error("编辑角色", e);
            result.setStatue(0);
        }
        return result;
    }

    /**
     * 删除角色
     */
    @ApiOperation(value = "删除角色", notes = "删除角色")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "Param", value = "删除角色参数", required = true, dataType = "DelRoleRequest", paramType = "body")
    })
    @PostMapping("DelUserRole")
    public ResponseBase DelUserRole(@RequestBody DelRoleRequest Param) {
        ResponseBase result = new ResponseBase();
        try {

        } catch (Exception e) {
            logger.error("删除角色", e);
            result.setStatue(0);
        }
        return result;
    }


    /**
     * 停用角色
     */
    @ApiOperation(value = "停用角色", notes = "停用角色")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "Param", value = "删除角色参数", required = true, dataType = "StopRoleRequest", paramType = "body")
    })
    @PostMapping("StopUserRole")
    public ResponseBase StopUserRole(@RequestBody StopRoleRequest Param) {
        ResponseBase result = new ResponseBase();
        try {

        } catch (Exception e) {
            logger.error("停用角色", e);
            result.setStatue(0);
        }
        return result;
    }

    /**
     * 编辑角色权限
     */
    @ApiOperation(value = "编辑角色权限", notes = "编辑角色权限")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "Param", value = "权限列表", required = true, dataType = "EditAuthorityRequest", paramType = "body")
    })
    @PostMapping("EditAuthority")
    public ResponseBase EditAuthority(@RequestBody EditAuthorityRequest Param) {
        ResponseBase result = new ResponseBase();
        try {

        } catch (Exception e) {
            logger.error("编辑角色权限", e);
            result.setStatue(0);
        }
        return result;
    }

    /**
     * 获取角色权限
     */
    @ApiOperation(value = "获取角色权限", notes = "获取角色权限")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "RoleID", value = "角色ID", required = true, dataType = "int", example = "0",defaultValue ="0" , paramType = "query")
    })
    @GetMapping("GetAuthorityList")
    public ResponseBase<List<t_sys_authority>> GetAuthorityList(@RequestParam int RoleID) {
        ResponseBase<List<t_sys_authority>> result = new ResponseBase<>();
        try {

        } catch (Exception e) {
            logger.error("编辑角色权限", e);
            result.setStatue(0);
        }
        return result;
    }

}
